/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.workforce.common.tags;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;

/**
 *
 * @author neo
 */
public class FieldForwardTag extends TagSupport {

    protected String go;
    protected String label;
    protected String name;
    protected String style;

    @Override
    public int doStartTag() throws JspException {
        JspWriter out = this.pageContext.getOut();
        StringBuffer s = new StringBuffer();
        s.append("<input type=\"button\" ");
        if( name != null ) {
        s.append("name=\"").append(name).append("\" ");
        } else {
            s.append("name=\"b").append(label.replaceFirst(" ", "_")).append("\" ");
        }
        s.append("value=\"").append(label).append("\" onClick=\"goAction('");
        s.append(go).append("')\"");
        if( style != null ) {
            s.append(" class=\"").append(style).append("\"");
        }
        s.append(">");
        try {
            out.print(s.toString());
        } catch(Exception ex) {
            ex.printStackTrace();
        }
        return SKIP_BODY;
    }

    public void setGo(String go) {
        this.go = go;
    }

    public void setLabel(String label) {
        this.label = label;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setStyle(String style) {
        this.style = style;
    }

   

}
